<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateNotesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('notes', function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();
            $table->text('content')->nullable()->comment('消息内容');
            $table->dateTime('create_time')->nullable()->comment('发布消息时间');
            $table->bigInteger('user_groups_id')->unsigned()->comment('所属群组id');
            $table->foreign('user_groups_id')->references('id')->on('user_groups');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('notes', function ($table) {
            $table->dropForeign(['user_groups_id']);
        });
        Schema::dropIfExists('notes');
    }
}
